home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Applications / Telnet Server 1.0 / interface.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-01-14  |  2.3 KB  |  118 lines  |  [TEXT/KAHL]

  1. /*
  2. Copyright © 1994 Mikhail Fridberg. Part of this code is copyrighted by Steve Falkenburg
  3.  
  4. Telnet-based talk server/client
  5.     
  6. connection management is done through the use of Operating System queues to simplify tracking
  7. and usage.
  8. */
  9.  
  10. #include <CommResources.h>
  11. #include <Terminals.h>
  12. #include <Connections.h>
  13.  
  14. #include "const.h"
  15. #include "globals.h"
  16. #include "utils.h"
  17. #include "interface.h"
  18.  
  19.  
  20. /*    initializes the user interface by loading our dialog into memory, and drawing the initial
  21.     queue numbers into the dialog
  22. */
  23.  
  24. void InitInterface(void)
  25. {
  26.     gMainDialog = GetNewDialog(kMainDialog,nil,(WindowPtr)-1L);
  27.     UpdateNumberList();
  28. }
  29.  
  30.  
  31. /*    displays the current values for the number of parameter blocks in each of the queues
  32.     (unused, running, completed)
  33. */
  34.  
  35. void UpdateNumberList(void)
  36. {
  37.     short iType;
  38.     Handle iHndl;
  39.     Rect iRect;
  40.     Str255 iText;
  41.     long lastValue;
  42.     
  43.     GetDItem(gMainDialog,kServicedItem,&iType,&iHndl,&iRect);
  44.     GetIText(iHndl,iText);
  45.     StringToNum(iText,&lastValue);
  46.     if (lastValue!=gServiced) {
  47.         NumToString(gServiced,iText);
  48.         SetIText(iHndl,iText);
  49.     }
  50.     
  51.     GetDItem(gMainDialog,kFreeItem,&iType,&iHndl,&iRect);
  52.     GetIText(iHndl,iText);
  53.     StringToNum(iText,&lastValue);
  54.     if (lastValue!=gFree) {
  55.         NumToString(gFree,iText);
  56.         SetIText(iHndl,iText);
  57.     }
  58.     
  59.     GetDItem(gMainDialog,kRunningItem,&iType,&iHndl,&iRect);
  60.     GetIText(iHndl,iText);
  61.     StringToNum(iText,&lastValue);
  62.     if (lastValue!=gRunning) {
  63.         NumToString(gRunning,iText);
  64.         SetIText(iHndl,iText);
  65.     }
  66.     
  67.     GetDItem(gMainDialog,kCompletedItem,&iType,&iHndl,&iRect);
  68.     GetIText(iHndl,iText);
  69.     StringToNum(iText,&lastValue);
  70.     if (lastValue!=gCompleted) {
  71.         NumToString(gCompleted,iText);
  72.         SetIText(iHndl,iText);
  73.     }
  74.     
  75.     GetDItem(gMainDialog,kGreetingItem,&iType,&iHndl,&iRect);
  76.     GetIText(iHndl,gGreetingData);
  77. }
  78.  
  79.  
  80. /*    handles events important to our dialog
  81. */
  82.  
  83. Boolean HandleDialogEvents(EventRecord *ev)
  84. {
  85.     DialogPtr theDlg;
  86.     short item;
  87.     
  88.     if (!IsDialogEvent(ev))
  89.         return false;
  90.     
  91.     if (DialogSelect(ev,&theDlg,&item)) {
  92.         if (item==kQuitItem)
  93.             gDone = true;
  94.     }
  95.     
  96.     return true;
  97. }
  98.  
  99.  
  100. /*    handles mouse down events.  we only do dragging, and nothing else
  101. */
  102.  
  103. void HandleMouseDown(Point mouseHit)
  104. {
  105.     WindowPtr window;
  106.     Rect limit;
  107.     
  108.     SetRect(&limit,-32000,-32000,32000,32000);
  109.     
  110.     switch (FindWindow(mouseHit,&window)) {
  111.         case inDrag:
  112.             DragWindow(window,mouseHit,&limit);
  113.         case inGoAway:
  114.             if (TrackGoAway(window,mouseHit))
  115.                 gDone = true;
  116.     }
  117. }
  118.